package cn.iocoder.an.module.mold.controller.admin.repairjob.vo;

import cn.iocoder.an.framework.excel.core.annotations.DictFormat;
import cn.iocoder.an.framework.excel.core.convert.DictConvert;
import cn.iocoder.an.framework.security.core.LoginUser;
import cn.iocoder.an.module.mold.dal.dataobject.account.AccountDO;
import cn.iocoder.an.module.mold.dal.dataobject.repaircategory.RepairCategoryDO;
import cn.iocoder.an.module.mold.dal.dataobject.repairfaultcategory.RepairFaultCategoryDO;
import com.fhs.core.trans.anno.Trans;
import com.fhs.core.trans.constant.TransType;
import com.fhs.core.trans.vo.VO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.util.*;

import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

import cn.idev.excel.annotation.*;

@Schema(description = "管理后台 - 模具维修任务 Response VO")
@Data
@ExcelIgnoreUnannotated
public class RepairJobRespVO implements VO {

    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "30860")
    @ExcelProperty("主键")
    private Long id;

    @Schema(description = "单号", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("单号")
    private String code;

    @Schema(description = "模具台账ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6570")
    @Trans(type = TransType.SIMPLE, target = AccountDO.class, fields = {"name", "code"}, refs = {"accountName", "accountCode"})
    private Long accountId;

    @ExcelProperty("模具名称")
    private String accountName;

    @ExcelProperty("模具编码")
    private String accountCode;

    @Schema(description = "维修分类Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4077")
    @Trans(type = TransType.SIMPLE, target = RepairCategoryDO.class, fields = {"name"}, refs = {"repairCategoryName"})
    private Long repairCategoryId;

    @ExcelProperty("维修分类名")
    private String repairCategoryName;

    @Schema(description = "故障分类Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16935")
    @Trans(type = TransType.SIMPLE, target = RepairFaultCategoryDO.class, fields = {"name"}, refs = {"faultName"})
    private Long faultId;

    @ExcelProperty("故障分类名")
    private String faultName;

    @Schema(description = "维修人Ids")
    @ExcelIgnore
    private List<Long> repairerIds;

    @Schema(description = "接收人Id", example = "16935")
    @Trans(type = TransType.SIMPLE, targetClassName = "cn.iocoder.an.module.system.dal.dataobject.user.AdminUserDO", fields = "nickname", ref = "assigneerName")
    private Long assigneerId;

    @Schema(description = "接收人名字")
    private Long assigneerName;

    @Schema(description = "接收时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("接收时间")
    private LocalDateTime jobReceiveTime;

    @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("开始时间")
    private LocalDateTime jobStartTime;

    @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("结束时间")
    private LocalDateTime jobEndTime;

    @Schema(description = "任务执行时长")
    @ExcelProperty("任务执行时长")
    private Double jobExecutionDuration;

    @Schema(description = "实际开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("实际开始时间")
    private LocalDateTime actualStartTime;

    @Schema(description = "实际结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("实际结束时间")
    private LocalDateTime actualEndTime;

    @Schema(description = "任务执行时长")
    @ExcelProperty("任务执行时长")
    private Double actualExecutionDuration;

    @Schema(description = "申请人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16366")
    @Trans(type = TransType.SIMPLE, targetClassName = "cn.iocoder.an.module.system.dal.dataobject.user.AdminUserDO", fields = "nickname", ref = "applicantName")
    private Long applicantId;

    @ExcelProperty("申请人")
    private String applicantName;

    @Schema(description = "申请部门", requiredMode = Schema.RequiredMode.REQUIRED, example = "21521")
    @Trans(type = TransType.SIMPLE, targetClassName = "cn.iocoder.an.module.system.dal.dataobject.dept.DeptDO", fields = "name", ref = "departName")
    private Long departId;

    @ExcelProperty("申请部门")
    private String departName;

    @Schema(description = "故障描述", example = "你猜")
    @ExcelProperty("故障描述")
    private String faultDescription;

    @Schema(description = "故障分析", example = "你猜")
    @ExcelProperty("故障分析")
    private String faultAnalysis;

    @Schema(description = "维修事项", example = "你猜")
    @ExcelProperty("维修事项")
    private String repairItems;

    @Schema(description = "维修成本")
    @ExcelProperty("维修成本")
    private Double repairCost;

    @Schema(description = "任务状态", example = "2")
    @ExcelProperty(value = "任务状态", converter = DictConvert.class)
    @DictFormat("mold_repair_status") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private Integer status;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("创建时间")
    private LocalDateTime createTime;

}
